package zero.tech.games.logic.topic;

import com.alibaba.fastjson.JSONObject;

import zero.tech.core.ZeroContext;
import zero.tech.games.common.TopicOrder;
import zero.tech.games.common.gm.GmForbitUser;
import zero.tech.games.logic.service.api.ILogicService;
import zero.tech.redis.topic.TopicChannelType;
import zero.tech.redis.topic.TopicProcess;
import zero.tech.wsnet.controller.CacheOnline;
import zero.tech.wsnet.controller.Controller;

public class ForbitUser extends TopicProcess{

	@Override
	public String orderType() {
		return TopicOrder.GM_FORBIT_USER;
	}

	@Override
	public void process(String message) throws Exception {
		GmForbitUser gmForbitUser = JSONObject.parseObject(message, GmForbitUser.class);
		ILogicService logicService = ZeroContext.getInstance(ILogicService.class);
		String service_id=logicService.getServiceId();
		if("ALL".equals(gmForbitUser.getService_id())||service_id.equals(gmForbitUser.getService_id())) {
			//全服封禁
			Controller controller=CacheOnline.getCache().getOnlines().get(gmForbitUser.getUid());
			if(controller!=null&&controller.getWebClient()!=null&&controller.getWebClient().isAlive()) {
				controller.getWebClient().activeClose();
			}
		}	
	}

	@Override
	public TopicChannelType channelType() {
		return TopicChannelType.DEFAULT;
	}

}
